package sg.edu.ntu.sci.blackboard.agilix.model;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author ngocgiang
 */
public class Message extends CourseElement {

    private static Log log = LogFactory.getLog(Message.class);

    public String getAttachment() {
        return attachment;
    }

    public void setAttachment(String attachment) {
        this.attachment = attachment;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getLocked() {
        return locked;
    }

    public void setLocked(String locked) {
        this.locked = locked;
    }

    public String getMyviews() {
        return myviews;
    }

    public void setMyviews(String myviews) {
        this.myviews = myviews;
    }

    public String getOwn() {
        return own;
    }

    public void setOwn(String own) {
        this.own = own;
    }

    public String getPostdate() {
        return postdate;
    }

    public void setPostdate(String postdate) {
        this.postdate = postdate;
    }

    public String getRead() {
        return read;
    }

    public void setRead(String read) {
        this.read = read;
    }

    public String getTotalviews() {
        return totalviews;
    }

    public void setTotalviews(String totalviews) {
        this.totalviews = totalviews;
    }

    public List<Message> getChildren() {
        return this.children;
    }

    public List<MessageAttachment> getAttachments() {
        return attachments;
    }

    public void printMessage() {
        //log.info("Message title = " + getTitle());
        try {
            String content = CourseElement.readFile(this);
            log.info(content);
        } catch (IOException e) {

        }
        
        for (Message child : children)
            child.printMessage();
    }

    private String author;
    private String own;
    private String locked;
    private String attachment;
    private String totalviews;
    private String read;
    private String postdate;
    private String myviews;
    private List<Message> children = new ArrayList<Message>();
    private List<MessageAttachment> attachments = new ArrayList<MessageAttachment>();
}
